﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIPPaser.Mod
{
    /// <summary>
    /// SIP消息定义
    /// </summary>
    public class SipMessage
    {
        /// <summary>
        /// 消息发送的时间
        /// </summary>
        public DateTime Time { get; set; }
        /// <summary>
        /// 消息类型
        /// </summary>
        public SIPMessageType MessageType { get; set; }
        public ProtocolType ProtocolType { get; set; }
        public string SrcIP { get; set; }
        public int SrcPort { get; set; }
        public string DstIP { get; set; }
        public int DstPort { get; set; }
     
        public int? StatusCode { get; set; }

        public string CallID { get; set; }
        public string FromSIPUrl { get; set; }
        public string FromTag { get; set; }
        public string ToSIPUrl { get; set; }
        public string ToTag { get; set; }

        public string SIPBody { get; set; }

        public string GetDisplayType()
        {
            if (this.MessageType == SIPPaser.Mod.SIPMessageType.REPLAY)
                return StatusCode.ToString();
            else
                return MessageType.ToString();

        }

        public override string ToString()
        {
            return string.Format("Time:{0:HH:mm:ss} Type:{1} StatusCode:{2} CallID:{3}", Time,MessageType,StatusCode,CallID);
        }
    }
}
